package cn.com.cabinet.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cabinet.web.entity.Seller;

import cn.com.cabinet.dao.SellerDao;
import cn.com.easy.utils.SecurityUtils;

@Service
public class SellerServiceImpl {
	@Autowired
	private SellerDao sellerDao;
	
	public void saveSeller(Seller s){
		sellerDao.save(s);
	}
	
	public Seller getSellerByICode(String Icode){
		return sellerDao.getSellerByICode(Icode);
		
	}
	
	public Seller getSellerBysPhone(String sPhone){
		return sellerDao.getSellerBysPhone(sPhone);
		
	}

	public Boolean getSellerBysAccountAndsPwd(String sAccount,String sPwd){
		
		
		Seller s = sellerDao.getSellerBysAccountAndsPwd(sAccount, SecurityUtils.SHA256(sPwd));
		if(s == null){
			//登录失败，账号不存在或密码错误
			return false;
		}else{
			//登录成功
			return true;
		}
		
		
	}
	
	
	public Seller getSellerBysAccount(String sAccount){
		return sellerDao.getSellerBysAccount(sAccount);
	}
}
